<?php

/**
* @copyright   (C) 2010 iJoomla, Inc. - All rights reserved.
* @license  GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) 
* @author  iJoomla.com webmaster@ijoomla.com
* @url   http://www.ijoomla.com/licensing/
* the PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript  
* are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 
* More info at http://www.ijoomla.com/licensing/
*/

	defined( '_JEXEC' ) or die( 'Restricted access' );
	
	$url        = JUri::root();
	$pathL 		= $url .'/images/sampledata'; //stories
	$pathA 		= JPATH_SITE .'/images/sampledata'; //stories
	$images 	= array();
	$folders 	= array();
	$folders[] 	= JHTML::_('select.option', '/' );
	$img_class = new Images();
	
	$img_class->ReadImages($pathA, '/', $folders, $images);	
?>

<script language="javascript" type="text/javascript">
	var folderimages = new Array ;
	<?php
		$i = 0 ;
		foreach ( $images as $k => $items ) {
			foreach ( $items as $v ) {
				echo "folderimages[" . $i++ . "] = new Array( '".$k."', '".addslashes( $v->value ) . "','" . addslashes( $v->text ) . "' );\n\t\t" ;
			}
		}
	?>
		
</script>

<div style="display:block; overflow:auto; height:325px; width:100%;">
	<table class="adminform" width="100%">
		<tr>
			<td colspan="3"><b><?php echo JText::_("COM_SURVEYS_SUB_FOLDER"); ?></b>: <?php echo $img_class->getFolders($folders, $pathL, ""); ?></td>
		</tr>
		<tr>
			<td width="45%" style="text-align: center"><b><?php echo JText::_("COM_SURVEYS_GALLERY_IMAGES"); ?></b>:</td>
			<td></td>
			<td width="45%" style="text-align: center"><b><?php echo JText::_("COM_SURVEYS_SURVEYS_IMAGES"); ?>:</b></td>
		</tr>
		<tr>
			<td width="45%" style="text-align:center;">				
				<?php echo $img_class->getImageFiles($images, $pathL); ?>
			</td>
			<td width="10%">
				<input class="button" type="button" value="<?php echo JText::_("COM_SURVEYS_ADD"); ?>" onClick="addSelectedToList('adminForm','imagefiles','imagelist')" /> <br />
				<input class="button" type="button" value="<?php echo JText::_("COM_SURVEYS_REMOVE"); ?>" onClick="delSelectedFromList('adminForm','imagelist')" />
			</td>
			<td width="45%" style="text-align:center;">				
				<?php 
					$survey_id = JRequest::getVar("id");
					echo $img_class->GetSavedImages($survey_id, $pathL, "pages"); ?>
			</td>
		</tr>		
		<tr>
			<td valign="top" align="left" width="50%">
				<div style="display:block; overflow:hidden; width:100%;" align="center">
					<img name="view_imagefiles" src="<?php echo JUri::base()."/components/com_surveys/images/blank.png"; ?>"/>
				</div>							
			</td>
			<td></td>			
			<td width="50%">				
				<?php if(isset($this->values) && $this->values != "" && $this->values["0"]["imagelist"] == ""){ ?>
						<div style="display:block; overflow:hidden; width:100%;" align="center">
							<img name="view_imagelist" src="<?php echo JUri::base()."/components/com_surveys/images/blank.png"; ?>"/>
						</div>
				<?php }elseif(isset($this->values) && $this->values != "" && $this->values["0"]["imagelist"] != ""){ ?>
						<div style="display:block; overflow:hidden; width:100%;" align="center">
							<img name="view_imagelist" src="<?php echo JUri::root()."images/sampledata/".$this->values["0"]["imagelist"]; ?>" />
						</div>
				<?php }else{ ?>
						<div style="display:block; overflow:hidden; width:100%;" align="center">
							<img name="view_imagelist" src="<?php echo JUri::base()."/components/com_surveys/images/blank.png"; ?>"/>
						</div>	
				<?php } ?>
			</td>
		</tr>	
					
	</table>
</div>